package com.gz.WeChatSys.controller;

import com.gz.WeChatSys.dto.ResultDTO;
import com.gz.WeChatSys.model.WxMpAutoreply;
import com.gz.WeChatSys.model.WxMpAutoreplyType;
import com.gz.WeChatSys.service.WxMpAutoreplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author lydia
 * @date 2018/9/28 下午5:11
 * @discription
 */
@RestController
@RequestMapping("/autoreply")
@Api(value = "自动回复接口",description = "自动回复案例查询")
public class WxMpAutoreplyController {
    private final static Logger logger = LoggerFactory.getLogger(WxMpAutoreplyController.class);

    @Autowired
    WxMpAutoreplyService wxMpAutoreplyService;

    @Resource
    WxMpService wxMpService;

    @ApiOperation(value = "获取自动回复案例类型",notes = "")
    @GetMapping("/getTypeList")
    public ResultDTO getTypeList(@RequestParam(name="userId",required=false) String userId,HttpServletRequest request,HttpServletResponse response){

        List<WxMpAutoreplyType> typeList = wxMpAutoreplyService.getTypeList();
        return ResultDTO.isOk().data(typeList);
    }

    @ApiOperation(value = "根据用户选择的类型id获取自动回复案例",notes = "")
    @GetMapping("/getAutoreplyByType")
    public ResultDTO getAutoreplyByType(@RequestParam("typeId") int typeId){

        List<WxMpAutoreply> autoreplyList = wxMpAutoreplyService.getAutoreplyByType(typeId);
        return ResultDTO.isOk().data(autoreplyList);
    }

}
